<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html;charset=utf-8" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>国内新闻 - 新华每日新闻</title>
	<link rel="stylesheet" href="<c:url value="/resources/css/index.css"/>"/>
    <script src="<c:url value="/resources/js/jquery-3.7.1.min.js"/>"></script>
    <style>
        .domestic-news-item{
            padding: 20px 0;
        }
    </style>
</head>
<body>
    <!-- 头部区域 -->
    <header class="news-header">
        <div class="header-top">
            <div class="date-time">2025年10月8日 星期三 16:17</div>
            <div class="weather">北京 晴 18°C</div>
        </div>
        
        <div class="logo-area">
            <h1 class="site-name">新华每日新闻</h1>
            <div class="header-right">
                <div class="search-bar">
                    <input type="text" placeholder="搜索新闻...">
                    <button>搜索</button>
                </div>
                <c:if test="${empty sessionScope.user}">
                    <button class="login-btn"><a href="<c:url value="/page/login"/>">登录</a></button>
                </c:if>
                <c:if test="${!empty sessionScope.user}">
                    <span class="welcome">欢迎，${sessionScope.user}</span><button class="login-btn"><a href="#" onclick="logout()">退出</a></button>
                </c:if>
            </div>
        </div>
        
        <nav class="main-nav">
            <ul>
                <li><a href="<c:url value="/page/homepage"/>">首页</a></li>
                <li><a href="<c:url value="/page/news?category=国内"/>">国内</a></li>
                <li><a href="<c:url value="/page/news?category=国际"/>">国际</a></li>
                <li><a href="<c:url value="/page/news?category=财经"/>">财经</a></li>
                <li><a href="<c:url value="/page/news?category=科技"/>">科技</a></li>
                <li><a href="<c:url value="/page/news?category=体育"/>">体育</a></li>
                <li><a href="<c:url value="/page/news?category=娱乐"/>">娱乐</a></li>
                <li><a href="<c:url value="/page/news?category=生活"/>">生活</a></li>
                <li><a href="<c:url value="/page/news?category=观点"/>">观点</a></li>
            </ul>
        </nav>
    </header>
    <script>
        var category="<%=request.getParameter("category")%>";
        $(".main-nav ul li").each(function() {
            if(decodeURIComponent(location.search).includes(category)){
                console.log($(this).children('a').html()===category)
                if($(this).children('a').html()===category){
                    $(this).addClass("active").siblings().removeClass("active");
                }
            }
        });
    </script>
    <!-- 主要内容区 -->
    <div class="container">
        <div class="main-content">
            <!-- 国内新闻专区 -->
            <section class="domestic-section">
                <h2 class="section-title"><%=request.getParameter("category")%>新闻</h2>
                <c:forEach items="${newsList}" var="item">
                <div class="domestic-news-list">
                    <article class="domestic-news-item">
                        <c:if test="${item.cover!=null}"><img src="${item.cover}" alt="${item.title}"></c:if>
                        <div class="domestic-news-info">
                            <h3><a href="<c:url value="/page/get/news?id=${item.id}"/>">${item.title}</a></h3>
                            <p>${item.content}</p>
                            <div class="domestic-news-meta">
                                <span class="source">${item.author}</span>
                                <span class="time">${item.air_time}</span>
                            </div>
                        </div>
                    </article>
                    </c:forEach>
                </div>
            </section>
        </div>
        
        <!-- 侧边栏 -->
        <aside class="sidebar">
            <div class="sidebar-widget hot-topics">
                <h3><%=request.getParameter("category")%>热点排行</h3>
                <ol>
                    <li>京津冀协同发展新规划发布</li>
                    <li>国庆假期旅游数据创新高</li>
                    <li>我国新能源装机容量突破12亿千瓦</li>
                    <li>全国铁路迎来返程客流高峰</li>
                    <li>全国秋粮收获已过六成</li>
                    <li>全国社保基金规模突破10万亿元</li>
                    <li>全国义务教育阶段学校课后服务全覆盖</li>
                    <li>全国高速公路免费通行结束</li>
                    <li>全国快递业务量突破1000亿件</li>
                    <li>全国多地迎来降温天气</li>
                </ol>
            </div>
        </aside>
    </div>
    
    <!-- 底部区域 - 精简版 -->
    <footer class="news-footer">
        <div class="footer-container">
            <div class="footer-links">
                <a href="#">关于我们</a>
                <a href="#">联系方式</a>
                <a href="#">广告服务</a>
                <a href="#">版权声明</a>
                <a href="#">隐私政策</a>
            </div>
            <div class="copyright">
                <p>© 2025 新华每日新闻 版权所有 ICP证：京ICP备12345678号</p>
            </div>
        </div>
    </footer>
    <script src="<c:url value="/resources/js/jquery-3.7.1.min.js"/>"></script>
    <script>
        function logout() {
            $(document).ready(function () {
                $.ajax({
                    url: '/logout',
                    type: 'get',
                    success: function (data) {
                        location.reload();
                    },
                    error: function (data) {
                        alert('出错了');
                    }
                });
            });
        }
    </script>
</body>
</html>
